<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/12
 * Time: 14:38
 */

namespace Modules\Api\Http\Controllers;

use Illuminate\Http\Request;
use Modules\Api\Service\AddressService;


class AddressController extends BaseController
{

    /**
     *  获取用户的所有地址
     *  hinq 2019 11 12
     *
     **/
    public function list(){
        $arr_list = AddressService::get_all();
        return response_json( $arr_list );
    }

    /**
     *  获取用户的默认地址
     *  hinq 2020 3 18
     **/
    public function get_defaule_address(){
        $arr_list = AddressService::get_defaule_address();
        return response_json( $arr_list );
    }



    /**
     *	添加收货地址
     *	hinq 2019 11 12
     *
     **/
    public function store( Request $request ){
        $arr_input = (array) $request->all();
        $arr_list = AddressService::store( (array) $arr_input );
        return response_json( $arr_list );
    }

    /**
     *	删除收货地址
     *	hinq 2019 11 12
     *
     **/
    public function delete( Request $request ){
        $nId = (int) $request->get('id');
        $arr_list = AddressService::delete( (int) $nId );
        return response_json( $arr_list );
    }

    /**
     *  获取指定的收货地址信息
     *  hinq 2019 11 12
     *
     **/
    public function info( Request $request ){
        $nId = (int) $request->get('id');
        $arr_list = AddressService::get_one( (int) $nId );
        return response_json( $arr_list );
    }

    /**
     *  编辑指定的收货地址信息
     *  hinq 2019 11 12
     *
     **/
    public function update( Request $request ){
        $arr_input = (array) $request->all();
        $arr_list = AddressService::update( (array) $arr_input );
        return response_json( $arr_list );
    }

    /**
     *  获取所有省份信息列表
     *  hinq 2019 11 21
     *
     **/
    public function get_address_list(Request $request){
        $arr_input = (array) $request->all();
        $arr_list = AddressService::get_address_list( (array) $arr_input );
        return response_json($arr_list);
    }
}